#ifndef _X86_DEFINATION__H_
#define _X86_DEFINATION__H_

#pragma pack(push)
#pragma pack(1)

typedef struct _IDT
{
	union
	{
		struct
		{
			UINT32 dwValue1;
			UINT32 dwValue2;
		};
		struct
		{
			UINT16 bSize;
			UINT32 dwBase;
			UINT16 bReserved;
		};
	};
}IDT, *PIDT, **PPIDT;

typedef struct _SELECTOR
{
	union
	{
		UINT16 wValue;
		struct
		{
			unsigned Rpl : 2;
			unsigned Ti : 1;
			unsigned Index : 13;
		};
	};
}SELECTOR, *PSELECTOR, **PPSELECTOR;

typedef struct _DTENTRY
{
	union
	{
		UINT64 qValue;
		struct  
		{
			UINT32 dReserved;
			unsigned bReserved2 : 8;
			unsigned Type : 4;//GATE_TASK,GATE_INTERRUPT,GATE_TRAP
			unsigned S : 1;//system or data ??
			unsigned Reserved3 : 3;
			unsigned wReserved4 : 16;
		};
	};
}DTENTRY, *PDTENTRY, **PPDTENTRY;
#define GATE_TASK 0x5
#define GATE_INTERRUPT 0x6
#define GATE_TRAP 0x7

typedef struct _GATE
{
	union
	{
		UINT64 qValue;
		struct  
		{
			unsigned wOffsetLow : 16;
			unsigned Selector : 16;
			unsigned bReserved : 8;
			unsigned Type : 3;//
			unsigned D : 1; // size of Gate, 1= 32bit , 0 = 16 bit , task gate should set to 0
			unsigned Reserved2 : 1; // should be 0
			unsigned DPL : 2; //
			unsigned P : 1;
			unsigned wOffsetHigh : 16;
		};
	};
}GATE, *PGATE, **PPGATE;


#pragma pack(pop)

#endif